package com.zcm.modules.cxf.web;

import com.aliyuncs.exceptions.ClientException;
import com.zcm.common.config.Constant;
import com.zcm.common.persistence.Page;
import com.zcm.common.utils.DateUtils;
import com.zcm.common.utils.IdGen;
import com.zcm.common.utils.StringUtils;
import com.zcm.modules.bzy.entity.*;
import com.zcm.modules.bzy.service.*;
import com.zcm.modules.center.entity.CenterUser;
import com.zcm.modules.center.service.CenterService;
import com.zcm.modules.center.service.CenterUserService;
import com.zcm.modules.center.utils.NoticeUtils;
import com.zcm.modules.cms.entity.Article;
import com.zcm.modules.cms.entity.ArticleData;
import com.zcm.modules.cms.entity.Category;
import com.zcm.modules.cms.entity.Site;
import com.zcm.modules.cms.service.ArticleDataService;
import com.zcm.modules.cms.service.ArticleService;
import com.zcm.modules.cms.utils.CmsUtils;
import com.zcm.modules.cxf.entity.*;
import com.zcm.modules.cxf.service.CxfSessionService;
import com.zcm.modules.cxf.utils.CxfMsgCodeUtils;
import com.zcm.modules.cxf.utils.RSAUtils;
import com.zcm.modules.nbg.entity.*;
import com.zcm.modules.nbg.service.*;
import com.zcm.modules.sys.service.SystemService;
import com.zcm.modules.sys.utils.DictUtils;
import com.zcm.modules.xgb.entity.XgbBoardDown;
import com.zcm.modules.xgb.entity.XgbBoardStock;
import com.zcm.modules.xgb.entity.XgbBoomStock;
import com.zcm.modules.xgb.entity.XgbHistoryData;
import com.zcm.modules.xgb.service.XgbBoardDownService;
import com.zcm.modules.xgb.service.XgbBoardStockService;
import com.zcm.modules.xgb.service.XgbBoomStockService;
import com.zcm.modules.zhaocai.entity.BZKB;
import com.zcm.modules.zhaocai.entity.DTB;
import com.zcm.modules.zhaocai.entity.Dadata;
import com.zcm.modules.zhaocai.entity.ZTB;
import com.zcm.modules.zhaocai.service.ZcmKanpanDataService;
import com.zcm.modules.zhaocai.utils.DDDataUtils;
import org.apache.http.util.TextUtils;
import org.apache.poi.ss.formula.atp.DateParser;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

@Controller
@RequestMapping(value = "${frontPath}/baba")
public class BabaController {
    @Autowired
    private StockGstcService stockGstcService;
    @Autowired
    private BzyLhbService bzyLhbService;
    @Autowired
    private BzyYmydService bzyYmydService;
    @Autowired
    private BzyJrjService bzyJrjService;
	@Autowired
	private XgbBoardStockService xgbBoardStockService;
	@Autowired
	private XgbBoomStockService xgbBoomStockService;
	@Autowired
	private XgbBoardDownService xgbBoardDownService;

	@Autowired
	private NbgBaseDataService nbgBaseDataService;
	@Autowired
	private NbgBeixuanService nbgBeixuanService;
	@Autowired
	private NbgFengkoService nbgFengkoService;
	@Autowired
	private NbgFengkoDetailService nbgFengkoDetailService;
	@Autowired
	private NbgJuechechiService nbgJuechechiService;
	@Autowired
	private NbgLtyaoguService nbgLtyaoguService;
	@Autowired
	private NbgZujichiService nbgZujichiService;

	@Autowired
	private CenterUserService centerUserService;
	@Autowired
	private ArticleService articleService;

	@Autowired
	private ZcmKanpanDataService zcmKanpanDataService;

	@Autowired
	private ArticleDataService articleDataService;
	@Autowired
	private CenterService centerService;
	@Autowired
	private CxfSessionService cxfSessionService;

	@Autowired
	private BzyQjwService bzyQjwService;

	@ResponseBody
	@RequestMapping("/logout")
	public BabaResponse logout(HttpServletRequest httpServletRequest){
		String sessionId = httpServletRequest.getHeader(Constant.SESSION_ID);
		CxfSession session = cxfSessionService.getBySessionId(sessionId);
		cxfSessionService.delete(session);
		return BabaResponse.ok();
	}

	@ResponseBody
	@RequestMapping("/login")
	public Result login(HttpServletRequest request,@RequestParam(value = "loginName")String loginName, @RequestParam(value = "password") String plainPassword) throws JSONException {
		String password = "";//centerService.getMD5(plainPassword);
		Result response = new Result();
		try {
			password = RSAUtils.decryptToStr(plainPassword, Constant.PRIVATE_KEY);
		} catch (Exception e) {
			e.printStackTrace();
			return Result.error(5,"密码不正确");
		}
		CenterUser centeruser = centerService.getUserByLoginName(loginName);
		if(centeruser==null){
			centeruser = centerService.getUserByMobile(loginName);
		}
		CxfSession session = cxfSessionService.getByUserName(loginName);
		if (session != null) {
			cxfSessionService.delete(session);
//			response.setResultCode(4);
//			response.setMessage("用户已经登陆，请误重复登陆！");
		}
		if (StringUtils.isBlank(loginName)) {
			return Result.error(1,"用户名不能为空");
		}
		if (StringUtils.isBlank(plainPassword)) {
			return Result.error(2,"密码不能为空");
		}
		if (null == centeruser || !SystemService.validatePassword(password,centeruser.getPassword())) {
			return Result.error(3,"用户名密码错误");
		}

		String sessionId = IdGen.uuid();
		CxfSession cxfSession = new CxfSession();
		cxfSession.setUser(centeruser);
		cxfSession.setSessionId(sessionId);
		cxfSessionService.save(cxfSession);
		centeruser.setLoginDate(new Date());
		centeruser.setLoginIp(StringUtils.getRemoteAddr(request));
		centerUserService.save(centeruser);
		return Result.ok("登陆成功").put("data",sessionId)
				.put("loginName",centeruser.getLoginName()).put("mobile",centeruser.getMobile());
	}

	@ResponseBody
	@RequestMapping("/dddata")
	public BabaResponse dddata(String day){
		Dadata dddata = getDData(day);
		return new BabaResponse(0,1L,"",dddata);
	}

	private Dadata getDData(String day) {
		String toDay = DateUtils.getDate();
		Dadata dddata = new Dadata();
		Boolean isLatest = StringUtils.isNotEmpty(day) && !toDay.equals(day);
		if(isLatest){
			DDDataUtils.parseKpData( zcmKanpanDataService.getDataByDay("boardStockTask",day),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getDataByDay("boomStockTask",day),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getDataByDay("boardDownTask",day),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getDataByDay("boardPredayTask",day),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getDataByDay("multiStockTask",day),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getDataByDay("realTask",day),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getDataByDay("quoteChangeTask",day),dddata);
		}else{
			DDDataUtils.parseKpData( zcmKanpanDataService.getLatestData("boardStockTask"),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getLatestData("boomStockTask"),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getLatestData("boardDownTask"),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getLatestData("boardPredayTask"),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getLatestData("multiStockTask"),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getLatestData("realTask"),dddata);
			DDDataUtils.parseKpData( zcmKanpanDataService.getLatestData("quoteChangeTask"),dddata);
		}
		return dddata;
	}

	@ResponseBody
	@RequestMapping("/ddqsdx")
	public BabaResponse ddqsdx(String day) {
		Dadata dddata = getDData(day);
		dddata.setLbggs(null);
		dddata.setYzbs(null);
		dddata.setSthsztb(null);
		dddata.setBzkbs(null);
		return new BabaResponse(0,1L,"",dddata);
	}

	@ResponseBody
	@RequestMapping("/ls_article")
	public BabaResponse ls_article(@RequestParam(defaultValue = "20") Integer pageSize, @RequestParam(defaultValue = "1")Integer pageNo) {
		CxfArticleListResponse response = new CxfArticleListResponse();
		BabaResponse babaResponse = new BabaResponse();

		String categoryId = DictUtils.getDictValue("zcm_article","zcm_config_catalog","");
		Category category1 = CmsUtils.getCategory(categoryId);
		if(category1 == null){
			return BabaResponse.error(1,"请传入资讯ID");
		}
		String siteId = CmsUtils.getCategory(categoryId).getSite().getId();

		Page<Article> page = new Page<Article>(pageNo,pageSize);
		Category category = new Category(categoryId, new Site(siteId));
		category.setParentIds(categoryId);
		Article article = new Article(category);
		article.setDelFlag(Article.DEL_FLAG_NORMAL);
		page = articleService.findPage(page, article, false);
		response.setTotal(page.getCount());
		response.setPageSize(pageSize);
		response.setPageNo(pageNo);
		response.setArticle(page.getList());
		babaResponse.setRet(0);
		babaResponse.setPageNo(pageNo);
		babaResponse.setPageSize(pageSize);
		babaResponse.setMessage("");
		babaResponse.setData(response.getArticles());
		babaResponse.setCount(page.getCount());
		return babaResponse;
	}

	@ResponseBody
	@RequestMapping("/show_atricle")
	public BabaResponse show_atricle(String id) {
		Map data = new HashMap();
		if(StringUtils.isBlank(id)){
			return BabaResponse.error(1,"请传入资讯ID");
		}
		ArticleData articleData = articleDataService.get(id);
		if(articleData == null){
			return BabaResponse.error(2,"该文章不存在");
		}
		Article article = articleService.get(id);
		article.getTitle();
		data.put("title",article.getTitle());
		data.put("content",articleData.getContent());
		data.put("pubDate",article.getCreateDate().getTime()/1000);
		data.put("copyFrom",articleData.getCopyfrom());

		return BabaResponse.ok(data);
	}

	@ResponseBody
	@RequestMapping("/msg_code")
	public BabaResponse msg_code(String mobile) {
		String code = CxfMsgCodeUtils.getMsgCode(mobile);
		if(!TextUtils.isEmpty(code)){
			return BabaResponse.error(1,"相同手机号一分钟内只能发送一次验证码");
		}
		String msgCode = NoticeUtils.randomCode();
		Map param = new HashMap();
		param.put("code",msgCode);

		CxfMsgCodeUtils.setMsgCode(mobile,msgCode);
		try {
			NoticeUtils.forgetPasswdMsg(param,mobile);
		} catch (ClientException e) {
			e.printStackTrace();
			return BabaResponse.error(2,e.getMessage());
		}
		return BabaResponse.ok();
	}

	@ResponseBody
	@RequestMapping("/forget_msg_code")
	public BabaResponse forget_msg_code(String loginName, String mobile) {
		CenterUser user;
		if(TextUtils.isEmpty(mobile)){
			user = centerService.getUserByLoginName(loginName);
		}else{
			user = centerService.getUserByMobile(mobile);
		}
		if(user==null || TextUtils.isEmpty(user.getMobile())){
			return BabaResponse.error(1,"和户名或者手机号不存在");
		}
		String code = CxfMsgCodeUtils.getMsgCode(user.getMobile());
		if(!TextUtils.isEmpty(code)){
			return BabaResponse.error(2,"相同手机号一分钟内只能发送一次验证码");
		}
		String msgCode = NoticeUtils.randomCode();
		Map param = new HashMap();
		param.put("code",msgCode);

		CxfMsgCodeUtils.setMsgCode(user.getMobile(),msgCode);
		try {
			NoticeUtils.forgetPasswdMsg(param,user.getMobile());
		} catch (ClientException e) {
			e.printStackTrace();
			return BabaResponse.error(3,"发送验证码失败");
		}
		return BabaResponse.ok();
	}

	@ResponseBody
	@RequestMapping("/forget_pwd")
	public BabaResponse forget_pwd(String loginName, String password, String mobile, String smgcode) {
		CenterUser user;
		if(TextUtils.isEmpty(mobile)){
			user = centerService.getUserByLoginName(loginName);
		} else{
			user = centerService.getUserByMobile(mobile);
		}
		if(user==null || TextUtils.isEmpty(user.getMobile())){
			return BabaResponse.error(1,"和户名或者手机号不存在");
		}

		String code = CxfMsgCodeUtils.getMsgCode(user.getMobile());
		if( !smgcode.equals(code) ){
			return BabaResponse.error(2,"手机验证码不正确");
		}
		if( TextUtils.isEmpty(password) ){
			return BabaResponse.error(3,"新密码为空");
		}
		user.setPassword(SystemService.entryptPassword(password));
		user.setUpdateDate(new Date());
		centerUserService.save(user);
		// 清除已经登陆的会话
		CxfSession session = cxfSessionService.getByUserName(user.getLoginName());
		if(session!=null){
			cxfSessionService.delete(session);
		}

		return BabaResponse.ok();
	}

	@ResponseBody
	@RequestMapping("/register")
	public BabaResponse register(String loginName, String password, String mobile, String smgcode) {
		CenterUser user = centerService.getUserByLoginName(loginName);
		if(user!=null){
			return BabaResponse.error(1,"用户名已存在");
		}
		user = centerService.getUserByMobile(mobile);
		if(user!=null){
			return BabaResponse.error(2,"手机号已注册");
		}
		if(TextUtils.isEmpty(smgcode)){
			return BabaResponse.error(3,"验证码不可为空");
		}
		if(TextUtils.isEmpty(password)){
			return BabaResponse.error(4,"密码不可为空");
		}
		String code = CxfMsgCodeUtils.getMsgCode(mobile);
		if(!smgcode.equals(code)){
			return BabaResponse.error(5,"验证码不正确");
		}

		user = new CenterUser();
		user.setLoginName(loginName);
		user.setPassword(SystemService.entryptPassword(password));
		user.setMobile(mobile);
		user.setAuditFlag("1");
		centerUserService.save(user);
		if (TextUtils.isEmpty(user.getId()) ) {
			return BabaResponse.error(6,"注册失败");
		}
		return BabaResponse.ok();
	}

	@ResponseBody
	@RequestMapping("/valid_username")
	public BabaResponse valid_username(String loginName) {
		return BabaResponse.ok(centerService.getUserByLoginName(loginName)==null);
	}

	@ResponseBody
	@RequestMapping("/valid_mobile")
	public BabaResponse valid_mobile(String mobile) {
		return BabaResponse.ok(centerService.getUserByMobile(mobile)==null);
	}

	@ResponseBody
	@RequestMapping("/nbg_baseData")
	public BabaResponse nbg_baseData(String day) {
		NbgBaseData nbgBaseData= new NbgBaseData();
		if(StringUtils.isEmpty(day)){
			day = String.format("%tF",new Date());
		}

		nbgBaseData.setRq(day);
		List list = nbgBaseDataService.findList(nbgBaseData);
		return BabaResponse.ok(list);
	}


	@ResponseBody
	@RequestMapping("/nbg_baseDataTop")
	public BabaResponse nbg_baseDataTop(String day) {
		NbgBaseData nbgBaseData= new NbgBaseData();
		if(StringUtils.isEmpty(day)){
			day = String.format("%tF",new Date());
		}
		Queue pq = new PriorityQueue();
		Map<String,Integer> map = new HashMap();

		nbgBaseData.setRq(day);
		List<NbgBaseData> list = nbgBaseDataService.findList(nbgBaseData);
		for (NbgBaseData o : list) {
			String title = o.getTitle();

			if (map.containsKey(title)) {
				map.put(title, map.get(title) + 1);
			} else {
				map.put(title, 1);
			}
		}

		ArrayList<Map.Entry<String, Integer>> listStatics =
				new ArrayList<Map.Entry<String, Integer>>(map.entrySet());
		Collections.sort(listStatics, new Comparator<Map.Entry<String, Integer>>() {
			@Override
			public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
				return o2.getValue().compareTo(o1.getValue());
			}
		});
		Map<String,List> topData = new LinkedHashMap<String, List>();
		for (int i=0;i<listStatics.size();i++) {
			if(i>4){ // 最大的四个。
				break;
			}
			topData.put(listStatics.get(i).getKey(),new ArrayList<NbgBaseData>());
		}
		for (NbgBaseData o : list) {
			String title = o.getTitle();
			if (topData.containsKey(title)) {
				topData.get(title).add(o);
			}
		}


		BabaResponse result = new BabaResponse();
		result.setRet(0);
		result.setCount((long)topData.size());
		result.setData(topData);
		return result;
	}

	@ResponseBody
	@RequestMapping("/nbg_beixuan")
	public BabaResponse nbg_beixuan(String day) {
		if(StringUtils.isEmpty(day)){
			day = String.format("%tF",new Date());
		}
		NbgBeixuan nbgBaseData= new NbgBeixuan();
		nbgBaseData.setRq(day);
		List  list = nbgBeixuanService.findList(nbgBaseData);
		return BabaResponse.ok(list);
	}

	@ResponseBody
	@RequestMapping("/nbg_fengko")
	public BabaResponse nbg_fengko(String day) {
		if(StringUtils.isEmpty(day)){
			day = String.format("%tF",new Date());
		}
		NbgFengko nbgFengko= new NbgFengko();
		nbgFengko.setRq(day);
		List  list = nbgFengkoService.findList(nbgFengko);
		return BabaResponse.ok(list);
	}


	@ResponseBody
	@RequestMapping("/nbg_fengkoDetail")
	public BabaResponse nbg_fengkoDetail(String fengkoId) {
		if(StringUtils.isBlank(fengkoId)){
			return BabaResponse.error(1,"请传入风口明细ID");
		}
		NbgFengkoDetail nbgFengkoDetail= new NbgFengkoDetail();
		nbgFengkoDetail.setFengkoId(fengkoId);
		List  list = nbgFengkoDetailService.findList(nbgFengkoDetail);
		return BabaResponse.ok(list);
	}

	@ResponseBody
	@RequestMapping("/nbg_juechechi")
	public BabaResponse nbg_juechechi(String day) {
		if(StringUtils.isEmpty(day)){
			day = String.format("%tF",new Date());
		}
		NbgJuechechi nbgJuechechi= new NbgJuechechi();
		nbgJuechechi.setRq(day);
		List  list = nbgJuechechiService.findList(nbgJuechechi);
		return BabaResponse.ok(list);
	}

	@ResponseBody
	@RequestMapping("/nbg_ltyaogu")
	public BabaResponse nbg_ltyaogu(String day) {
		if(StringUtils.isEmpty(day)){
			day = String.format("%tF",new Date());
		}
		NbgLtyaogu nbgLtyaogu= new NbgLtyaogu();
		nbgLtyaogu.setRq(day);
		List  list = nbgLtyaoguService.findList(nbgLtyaogu);
		return BabaResponse.ok(list);
	}

	@ResponseBody
	@RequestMapping("/nbg_zujichi")
	public BabaResponse nbg_zujichi(String day) {
		if(StringUtils.isEmpty(day)){
			day = String.format("%tF",new Date());
		}
		NbgZujichi nbgZujichi= new NbgZujichi();
		nbgZujichi.setRq(day);
		List  list = nbgZujichiService.findList(nbgZujichi);
		return BabaResponse.ok(list);
	}

	@ResponseBody
	@RequestMapping("/xgb_ggxx")
	public BabaResponse xgb_ggxx(String symbol) {
		if(StringUtils.isBlank(symbol)){
			return BabaResponse.error(1, "请传入股票代码");
		}
		String stockName = "";
		List<XgbHistoryData> list = new ArrayList<XgbHistoryData>();
		XgbBoardStock xgbBoardStock = new XgbBoardStock();
		xgbBoardStock.setSymbol(symbol);
		List<XgbBoardStock> xgbBoardStocks = xgbBoardStockService.findList(xgbBoardStock);
		if(xgbBoardStocks.size()>0){
			stockName = xgbBoardStocks.get(0).getTitle();
		}
		XgbBoomStock xgbBoomStock = new XgbBoomStock();
		xgbBoomStock.setSymbol(symbol);
		List<XgbBoomStock> xgbBoomStocks = xgbBoomStockService.findList(xgbBoomStock);

		if("".equals(stockName) && xgbBoomStocks.size()>0){
			stockName = xgbBoomStocks.get(0).getTitle();
		}
		XgbBoardDown xgbBoardDown = new XgbBoardDown();
		xgbBoardDown.setSymbol(symbol);
		List<XgbBoardDown> xgbBoardDowns = xgbBoardDownService.findList(xgbBoardDown);

		if("".equals(stockName) && xgbBoardDowns.size()>0){
			stockName = xgbBoardDowns.get(0).getTitle();
		}
//		final String finalStockName = stockName;
//		Map<String,String> params = new HashMap<String, String>(){{
//			put("stockName", finalStockName);
//			put("day", finalStockName);
//		}};
//		zcmKanpanDataService.getBoomDownReason()

		for (XgbBoardStock bs : xgbBoardStocks ) {
			XgbHistoryData xgbHistoryData = new XgbHistoryData();
			xgbHistoryData.setContinueBoardCount(bs.getContinueBoardCount());
			xgbHistoryData.setDay(bs.getDay());
			xgbHistoryData.setReason(bs.getReason());
			xgbHistoryData.setSymbol(bs.getSymbol());
			xgbHistoryData.setTitle(bs.getTitle());
			xgbHistoryData.setTime(bs.getLastRaiseTime());
			xgbHistoryData.setCurPrice(bs.getCurPrice());
			xgbHistoryData.setPxChangeRate(bs.getPxChangeRate());
			xgbHistoryData.setType("涨停板");
			list.add(xgbHistoryData);
		}

		for (XgbBoomStock bs : xgbBoomStocks ) {
			XgbHistoryData xgbHistoryData = new XgbHistoryData();
			xgbHistoryData.setContinueBoardCount(bs.getContinueBoardCount());
			xgbHistoryData.setDay(bs.getDay());
			xgbHistoryData.setReason(bs.getReason());
			xgbHistoryData.setSymbol(bs.getSymbol());
			xgbHistoryData.setTitle(bs.getTitle());
			xgbHistoryData.setTime(bs.getLastBoomTime());
			xgbHistoryData.setCurPrice(bs.getCurPrice());
			xgbHistoryData.setPxChangeRate(bs.getPxChangeRate());
			xgbHistoryData.setType("被砸开板");
			list.add(xgbHistoryData);
		}


		for (XgbBoardDown bs : xgbBoardDowns ) {
			XgbHistoryData xgbHistoryData = new XgbHistoryData();
			xgbHistoryData.setContinueBoardCount(bs.getContinueBoardCount());
			xgbHistoryData.setDay(bs.getDay());
			xgbHistoryData.setReason(bs.getReason());
			xgbHistoryData.setSymbol(bs.getSymbol());
			xgbHistoryData.setTitle(bs.getTitle());
			xgbHistoryData.setTime(bs.getLastBoardTime());
			xgbHistoryData.setCurPrice(bs.getCurPrice());
			xgbHistoryData.setPxChangeRate(bs.getPxChangeRate());
			xgbHistoryData.setType("跌停板");
			list.add(xgbHistoryData);
		}

		Collections.sort(list, new Comparator<XgbHistoryData>() {
			@Override
			public int compare(XgbHistoryData o1, XgbHistoryData o2) {
				return o1.getDay().compareTo(o2.getDay());
			}
		});

		return BabaResponse.ok(list);
	}
    @ResponseBody
    @RequestMapping("/bzy_jrj")
    public BabaResponse bzy_jrj(BzyJrj bzyJrj) {
	    List list = bzyJrjService.findList(bzyJrj);
        return BabaResponse.ok(list);
    }

    @ResponseBody
    @RequestMapping("/bzy_ymyd")
    public BabaResponse bzy_ymyd(BzyYmyd bzyYmyd) {
        List list = bzyYmydService.findList(bzyYmyd);
        return BabaResponse.ok(list);
    }

	@ResponseBody
	@RequestMapping("/stock_gstc")
	public BabaResponse stock_gstc(StockGstc stockGstc) {
		List list = stockGstcService.findList(stockGstc);
		return BabaResponse.ok(list);
	}
    @ResponseBody
    @RequestMapping("/bzy_lhb")
    public BabaResponse bzy_lhb(BzyLhb bzyLhb) {
        List<BzyLhb> list = bzyLhbService.findList(bzyLhb);
		if(StringUtils.isNotBlank(bzyLhb.getType())){
			return BabaResponse.ok(list);
		}
		List<BzyLhb> retList = new ArrayList<BzyLhb>();
		Set<String> days = new HashSet<String>();
		for (BzyLhb lhb : list) {
			String [] dt = StringUtils.split(lhb.getTime()," ");
			if(dt.length<1){
				continue;
			}
			days.add(dt[0]);
			if(days.size()>5){
				break;
			}
			retList.add(lhb);
		}
        return BabaResponse.ok(retList);
    }


	@ResponseBody
	@RequestMapping("/bzy_news")
	public BabaResponse bzy_news(BzyYmyd bzyYmyd) {
		bzyYmyd.setUnionFlag(1);
		List list = bzyYmydService.findList(bzyYmyd);
		return BabaResponse.ok(list);
	}

	@ResponseBody
	@RequestMapping("/bzy_qjw")
	public BabaResponse bzy_qjw(BzyQjw bzyQjw) {
		List list = bzyQjwService.findList(bzyQjw);
		return BabaResponse.ok(list);
	}
    @ResponseBody
    @RequestMapping("/wwwtest")
    public BabaResponse wwwtest(HttpServletRequest request) {
		BzyLhb bzyLhb = new BzyLhb();

        return bzy_lhb(bzyLhb);
    }
}
